var e = require;
var t = module;
var n = e("SoundMgr").default;
window.ColourBackground = {
    Instance: null
};
cc.Class({
    extends: cc.Component,
    properties: {
        UpdateFadeSpeed: 100,
        DeathAudioClips: {
            type: [cc.AudioClip],
            default: []
        },
        UpdateFlag: 0
    },
    onLoad: function() {
        ColourBackground.Instance = this;
        this.node.active = !1
    },
    update: function(e) {
        if (0 != this.UpdateFlag) switch (this.UpdateFlag) {
            case 1:
                if (this.node.opacity >= 255) {
                this.UpdateFlag = 2;
                this.scheduleOnce(function() {
                    this.UpdateFlag = 3
                },
                1.2)
            } else this.node.opacity += this.UpdateFadeSpeed * e;
            break;
            case 3:
                this.node.opacity -= this.UpdateFadeSpeed * e;
            if (this.node.opacity <= 0) {
                this.UpdateFlag = 0;
                this.node.active = !1
            }
        }
    },
    Show: function(e) {
        void 0 === e && (e = cc.color(0, 0, 0));
        this.unscheduleAllCallbacks(this);
        e.equals(cc.color(0, 0, 0)) && n.Instance.playSoundClip(this.DeathAudioClips[Math.round(Math.random() * this.DeathAudioClips.length - 1)]);
        this.node.opacity = 0;
        this.node.active = !0;
        this.node.color = e;
        this.UpdateFlag = 1
    }
})